<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        var id=getQuery("id");
        var userId;
        function  getUserAccount(){
            axios.get("/user/getUserAcc",null).then(e =>{
                var user = e.data;
                userId = user.id;
                $("acc").innerText = user.acc;
                $("date").innerText = user.creatDate;
            })
        }



        function showP(){
            axios.get("/post/findById",{
                params:{
                    id
                }
            }).then(e =>{
                var post = e.data;
                $("title").innerText = post.title;
                $("cDate").innerText = post.date;
                $("content").innerText =post.content;

                var str="";
                for (var i=0;i<post.replyList.length;i++){

                    var obj = post.replyList[i];

                    str +=`标题:<span>${obj.title}</span><br>
                    内容:<span>${obj.content}</span><br>`
                }
                $("reply").innerHTML = str;

            })
        }


        function addR(){
            axios.get("/reply/addR",{
                params: {
                    title:$("replyTitle").value,
                    content:$("replyContent").value,
                    postId:id,
                    userId:userId,
                }
            }).then(e=>{
                if (e.data =="ok"){
                    showP();
                }

            })
        }


        window.onload = function (){
            showP();
            getUserAccount();
        }




    </script>
</head>
<body>
楼主:<span id="acc"></span>
注册时间:<span id="date"></span>
主题:<span id="title"></span>
@<span id="cDate"></span>
<span id="content"></span><br>
<span>内容子帖</span>
<div id="reply"></div><br>
回复:<br>
标题:<input type="text" id="replyTitle"><br>
内容:<textarea id="replyContent" style="width: 150px;height: 150px"></textarea><br>
<input type="button" value="发表" onclick="addR()">

</body>
</html>